package com.yh.csx.crm.core.enums;

import java.util.EnumSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * PaymentDaysEnum class
 * 01转账、02现金（刷卡）、03支票、04信控、05账扣五种类型
 * @author huyalin
 * @date 2019/2/21
 */
public enum PaymentModeEnum {
    TRANSFER("01", "转账"),
    CASH("02", "现金（刷卡）"),
    CHEQUE("03", "支票"),
    CREDIT("04", "信控"),
    KEEP_ACCOUNTS("05", "账扣");

    private String code;
    private String name;

    PaymentModeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    private static final Map<String, PaymentModeEnum> valueLookup = new ConcurrentHashMap<>(values().length);
    static {
        for (PaymentModeEnum type : EnumSet.allOf(PaymentModeEnum.class)) {
            valueLookup.put(type.code, type);
        }
    }

    public static PaymentModeEnum resolve(String code) {

        return (code != null ? valueLookup.get(code) : null);
    }

    public static String resolveName(String code) {
        PaymentModeEnum mode = resolve(code);
        return mode == null ? "" : mode.getName();
    }
}
